<?php include(TPL_PATH . '/admin/inc_header.php'); ?>
<?php include(TPL_PATH . '/admin/inc_top.php'); ?>

<form action="<?php p(HTTP_URL); ?>/index.php?m=admin&c=acl&a=edit&id=<?php p($id) ?>" method="post">
    <fieldset>
    	<legend>编辑元素</legend>
        <label for="id_name">中文名称</label>
        <input type="text" name="name" id="id_name" value="<?php p($arrData['name']) ?>" />
        <label for="id_name_en">英文名称</label>
        <input type="text" name="name_en" id="id_name_en" value="<?php p($arrData['name_en']) ?>" />
        <label for="id_title">说明文字</label>
        <input type="text" name="title" id="id_title" class="input-large" value="<?php p($arrData['title']) ?>" />
        <br />
        <input type="submit" class="btn btn-primary" name="sub_btn_0" value="保存修改" />
        <a href="<?php p(HTTP_URL) ?>/index.php?m=admin&c=acl" class="btn">返回列表</a>
    </fieldset>
</form>

<?php if ('g' == $arrData['type']) { ?>
<form class="table table-bordered table-condensed" action="<?php p(HTTP_URL); ?>/index.php?m=admin&c=acl&a=edit&id=<?php p($id) ?>" method="post">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr>
		<td colspan="<?php p(count($arrAction) + 2) ?>">
			<ul class="breadcrumb" style="margin:0px;">
				<li>权限设置</li>
			</ul>
		</td>
	</tr>
	<tr>
		<th rowspan="2">操作对象</th>
		<th colspan="<?php p(count($arrAction) + 1) ?>">操作类型</th>
	</tr>
	<tr>
		<td ><label class="checkbox" title="所有全选"><input id="qs_all" class="qs" type="checkbox" /><i>全选</i></label></td>
		<?php foreach ($arrAction as $arrC) { ?>
		<td><label class="checkbox" title="竖向全选"><input class="qs all_box" id="qs_s_<?php p($arrC['id']) ?>" type="checkbox" /><i>全选</i></label></td>
		<?php } ?>
	</tr>
	<?php foreach ($arrProject as $arrP) { ?>
	<tr>
		<td title="<?php p($arrP['title']) ?>"><?php p($arrP['name']) ?></td>
		<td><label class="checkbox" title="横向全选"><input class="qs all_box" id="qs_h_<?php p($arrP['id']) ?>" type="checkbox" /><i>全选</i></label></td>
		<?php foreach ($arrAction as $arrC) { ?>
		<td><label class="checkbox" title="<?php p($arrC['title']) ?>"><input id="<?php p($arrP['id']) ?>_<?php p($arrC['id']) ?>" name="checked_values[]" value="<?php p($arrP['id']) ?>|<?php p($arrC['id']) ?>|<?php p($arrP['name_en']) ?>|<?php p($arrC['name_en']) ?>" class="all_box h_<?php p($arrP['id']) ?> s_<?php p($arrC['id']) ?>" type="checkbox" /><?php p($arrC['name']) ?></label></td>
		<?php } ?>
	</tr>
	<?php } ?>
	<tr>
		<td colspan="<?php p(count($arrAction) + 2) ?>" style="text-align:center;">
			<input type="submit" class="btn btn-primary" name="sub_btn" value="保存设置" />
		</td>
	</tr>
</table>
</form>

<script type="text/javascript">
var blnTemp;
var strCheck = '<?php p($strCheck) ?>';
$(document).ready(function() {
	if (strCheck.length > 1) {
		$(strCheck).each(function() {
			this.checked = true;
		});
	}
	set_bg();
});

function set_bg() {
	$(":checkbox[name='checked_values[]']").each(function() {
		$(this).parent().parent().css('background-color', this.checked ? 'silver' : 'white');
	});
	setTimeout(set_bg, 500);
}

$('.qs').each(function() {
	$(this).click(function() {
		var _this = $(this);
		var id = _this.attr('id');
		var d = 'all';
		if ('qs_all' == id) {
			id = 'box';
		} else if (id.indexOf('qs_s_') > -1) {
			id = id.replace('qs_s_', '');
			d = 's';
		} else if (id.indexOf('qs_h_') > -1) {
			id = id.replace('qs_h_', '');
			d = 'h';
		}
		blnTemp = this.checked;
		$('.' + d + '_' + id).each(function() {
			this.checked = blnTemp;
		});
	});
});
</script>
<?php } ?>

<?php include(TPL_PATH . '/admin/inc_bottom.php'); ?>
<?php include(TPL_PATH . '/admin/inc_footer.php'); ?>